/* GUI CONVERTED from rwroiq04.p (converter v1.75) Wed May 16 13:34:18 2001 */
/* rwroiq04.p - ROUTING OPERATION COST INQUIRY (iro_det)                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.9 $                                                     */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 7.3      LAST MODIFIED: 02/18/93   BY: emb *G701*          */
/* REVISION: 7.3      LAST MODIFIED: 02/02/95   BY: cpp *G0DL*          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 02/25/98   BY: *K1JC* Beena Mol    */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*                  */
/* $Revision: 1.9 $    BY: Hualin Zhong   DATE: 05/04/01 ECO: *N0YC*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE          */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rwroiq04_p_1 "Op Total"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwroiq04_p_2 "Cum Total"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable part like pt_bom_code.
define variable desc1 like pt_desc1.
define variable site like iro_site.
define variable routing like iro_routing.
define variable bom_code like pt_bom_code.
define variable csset like iro_cost_set.
define variable no_routing_indic as character format "x(1)".
define variable routing_op_exists like mfc_logical initial yes.

assign
   part = global_part
   site = global_site.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   site csset routing part
with frame a width 80 no-underline attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}

repeat:

   if c-application-mode <> 'web' then
   update
      site
      csset
      routing
      part
   with frame a
   editing:

      /* FIND NEXT/PREVIOUS RECORD */
      {mfnp.i iro_det part iro_part part iro_part iro_det}

      if recno <> ? then do:
         display
            iro_part @ part
            iro_site @ site
            iro_cost_set @ csset
            iro_routing @ routing
         with frame a.
         recno = ?.
      end.
   end.
   status input.

   {wbrp06.i &command = update &fields = "  site csset routing part"
      &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      routing_op_exists = yes.

      find si_mstr no-lock where si_site = site no-error.
      if not available si_mstr then do:
         {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3} /* SITE DOES NOT EXIST */
         if c-application-mode = 'web' then return.
         undo, retry.
      end.

      find cs_mstr where cs_set = csset no-lock no-error.
      if not available cs_mstr then do:
         {pxmsg.i &MSGNUM=5407 &ERRORLEVEL=3} /* COST SET DOES NOT EXIST */
         if c-application-mode = 'web' then return.
         else next-prompt csset.
         undo, retry.
      end.

      if csset = "" then do:
         {pxmsg.i &MSGNUM=40 &ERRORLEVEL=3}  /* BLANK NOT ALLOWED */
         if c-application-mode = 'web' then return.
         else next-prompt csset.
         undo, retry.
      end.

      /* FIND ITEM ROUTING COST DETAIL RECORD */
      find first iro_det no-lock where iro_part = part
         and iro_site = site
         and iro_cost_set = csset
         and iro_routing = routing
         no-error.
      if not available iro_det then do:
         {pxmsg.i &MSGNUM=1614 &ERRORLEVEL=2}
         /*SELECTION CRITERIA RESULTS IN NO DATA TO RPT*/
      end.

      find first ro_det no-lock
         where ro_routing = iro_routing
         and ro_op = iro_op  no-error.
      if not available ro_det then do:
         {pxmsg.i &MSGNUM=126 &ERRORLEVEL=2}  /* ROUTING DOES NOT EXIST */
      end.

      find pt_mstr no-lock where pt_part = part no-error.
      if available pt_mstr then global_part = part.

      global_site = site.

      hide frame c.

   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   for each iro_det no-lock where iro_part = part
         and iro_site = site
         and iro_cost_set = csset
         and iro_routing = routing
         break by iro_part by iro_site
         by iro_cost_set by iro_routing by iro_op
      with frame c:

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      FORM /*GUI*/ 
         no_routing_indic  format "x(1)" column-label " "
         iro_op
         iro_mtl_tl format "->>>,>>9.99<<<"
         iro_lbr_tl format "->>,>>9.99<<<"
         iro_bdn_tl format "->>>,>>9.99<<<"
         iro_sub_tl format "->>>,>>9.99<<<"
         iro_value01 format "->>>,>>9.99<<<" column-label {&rwroiq04_p_1}
         iro_cost_tot format "->>>,>>9.99<<<" column-label {&rwroiq04_p_2}
      with STREAM-IO /*GUI*/  frame c width 80 no-attr-space.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame c:handle).

      if first-of (iro_routing)
         and iro_mtl_ll <> 0 then do:
         display
            iro_mtl_ll @ iro_mtl_tl
            iro_mtl_ll @ iro_value01
            iro_mtl_ll @ iro_cost_tot WITH STREAM-IO /*GUI*/ .
         down 1.
      end.

      find last ro_det no-lock
         where ro_routing = iro_routing
         and ro_op = iro_op  no-error.
      if available ro_det
         then no_routing_indic = " ".
      else
      assign
         no_routing_indic = "*"
         routing_op_exists = no.

      display
         no_routing_indic
         iro_op
         iro_mtl_tl
         iro_lbr_tl
         iro_bdn_tl
         iro_sub_tl
         iro_mtl_tl + iro_lbr_tl + iro_bdn_tl + iro_sub_tl @ iro_value01
         iro_cost_tot
      with frame c STREAM-IO /*GUI*/ .
   end.

   if routing_op_exists = no then do:
      if c-application-mode <> 'web' then do:
         /* ROUTING/OPERATION DELETED. RERUN OPERATION COST CALCULATION */
         {pxmsg.i &MSGNUM=3658 &ERRORLEVEL=1}
         pause 3.
      end.
   end.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}  /* LIST COMPLETE */

end.

{wbrp04.i &frame-spec = a}
